<template>
  <div>
    <el-date-picker
      v-model="selectDate"
      size="mini"
      type="datetime"
      :picker-options="{
        disabledDate(time){
          return time.getTime() < Date.now()-1 * 24 * 3600 * 1000 //Date.now() - 8.64e7
        },
        selectableRange: selectDate <= Date.now() ? getTimes + '-23:59:59' : '00:00:00' + '-23:59:59'
      }"
      @change="handle"
      placeholder="选择日期时间">
      </el-date-picker> 
  </div>
  </div>
</template>
<script>
import {nowTime} from '../../utils/times'
export default {
  data() {
    return {
      selectDate: '',
      getTimes: nowTime().substring(11),
      arr:[1, 2, 5, 7, 3],
      brr: [2, 3],
      itemAry: [],
      flag: false
    }
  },
  mounted() {
    this.selectDate = nowTime();
    console.log("selectDate:", this.selectDate, this.getTimes);

    this.isInclude(this.arr, this.brr);
    console.log("flag", this.flag, "brr:", this.brr, "itemAry:", this.itemAry)
  },
  methods: {
    isInclude(a, b){
      this.itemAry = [];
      a.forEach((item)=>{
        b.forEach((k)=>{
          if(item == k){
            this.itemAry.push(item)     
          }

        })
      })

      if(this.itemAry.length == b.length){
        return this.flag = true;
      }else{
        return this.flag = false;
      }
    },
    handle() {
      var startAt = new Date(this.selectDate) * 1000 /1000;
      // 如果输入时间，小于当前时间就自动改为当前时间
      if(startAt < Date.now()) {
        this.selectDate = new Date();
      }
    },
  }
};
</script>
<style>
.el-time-panel__btn{
  display: inline-block !important;
}
button {
  padding: 0;
}
.el-time-panel__content::after, .el-time-panel__content::before {
  margin-top: -8px !important;
}
</style>